﻿using AdminSystem.Applications;
using AdminSystem.Domain.User;
using AdminSystem.Write.API.Command.EnterprisesCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace AdminSystem.Write.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class EnterpriseController : ControllerBase
    {
        public EnterpriseController(IMediator mediator)
        {
            Mediator = mediator;
        }

        public IMediator Mediator { get; }

        /// <summary>
        /// 中介者添加企业
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<object>> EnterpriseAdd(EnterpriseCommand command)
        {
            return await Mediator.Send(command);
        }
        /// <summary>
        /// 中介者查询企业
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<Enterprise>> EnterpriseQuery()
        {
            EnterpriseQueryCommand command = new EnterpriseQueryCommand();
            return await Mediator.Send(command);
        }
    }
}
